package com.java.mapper;

import com.java.pojo.CheckReveal;
import com.java.pojo.Course_info;
import com.java.pojo.Teacher_info;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * description:描述
 * author:作者
 * time:2020/11/24 21:30
 */
public interface TeacherFunctionMapper {

    /**
     *通过微信Id来查询教师的详细信息
     * @param teacherWxid
     * @return
     */
    @Select("SELECT * FROM teacher_info WHERE teacherWxid=#{arg0}")
    Teacher_info selectStudentInfoByWxid(String teacherWxid);

    /**
     * 注册修改教师信息
     * @param teacher_info
     * @return
     */
    @Update("UPDATE teacher_info SET teacherName=#{teacherName},code=#{code} WHERE teacherWxid=#{teacherWxid}")
    int alertTeacherInfo(Teacher_info teacher_info);

    /**
     *通过微信Id来查询教师的课程信息
     * @param teacherUuid
     * @return
     */
    @Select("SELECT * FROM info_course WHERE teacher_id=#{arg0}")
    List<Course_info> selectCourseInfoByTeacherId(String teacherUuid);

    /**
     * 教师根据微信id获取Uuid
     * @param
     * @return
     */
    @Select("SELECT uuid FROM teacher_info where teacherWxid=#{arg0}")
    String getUuidByWxid(String teacherWxid);

    /**
     * 添加课程
     * @param course_info
     * @return
     */
    @Insert("INSERT INTO info_course VALUES(#{uuid},#{course_name},#{teacher_id},#{course_sum},#{course_now},#{comment},0)")
    int addCourseInfo(Course_info course_info);

    /**
     * 修改课程
     * @param course_info
     * @return
     */
    @Update("UPDATE info_course SET course_name=#{course_name},course_sum=#{course_sum},course_now=#{course_now},comment=#{comment} WHERE uuid=#{uuid}")
    int updateCourseInfo(Course_info course_info);

    /**
     * 教师删除课程
     * @param
     * @return
     */
    @Delete("DELETE FROM info_course WHERE uuid=#{arg0}")
    int deleteStudentCourseInfo(String uuid);

    /**
     * 发起签到
     * @param uuid
     * @param courseNow
     * @return
     */
    @Update("UPDATE info_course SET check_flag=1,course_now=#{arg1} WHERE uuid=#{arg0}")
    int beginCheck(String uuid, String courseNow);

    /**
     * 终止签到
     * @param uuid
     * @return
     */
    @Update("UPDATE info_course SET check_flag=0 WHERE uuid=#{uuid}")
    int endCheck(String uuid);

    /**
     *课程签到情况展示
     * @param courseId,courseNum
     * @return
     */
    @Select("SELECT * FROM check_reveal WHERE course_uuid=#{arg0} and (course_num=#{arg1} or course_num is null)")
    List<CheckReveal> checkListReveal(String courseId,String courseNum);




}
